package com.weiwei.diancan.adapter;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.weiwei.diancan.R;
import com.weiwei.diancan.bean.LoginBean;

import java.util.List;

import weiwei.com.weiweilibrary.adapter.BaseQuickAdapter;
import weiwei.com.weiweilibrary.holder.BaseViewHolder;

/**
 * Created by BMW on 2016/11/7.
 */
public class OpenTypeAdapter extends BaseQuickAdapter<LoginBean.MenuListBean> {

    private List<LoginBean.MenuListBean> data;
    private Context context;
    public OpenTypeAdapter(List<LoginBean.MenuListBean> data, Context context) {
        super(R.layout.item_main_type, data);
        this.context = context;
        this.data = data;
    }

    @Override
    public List<LoginBean.MenuListBean> getData() {
        return data;
    }

    @Override
    public void setNewData(List<LoginBean.MenuListBean> data) {
        super.setNewData(data);
        this.data = data;
    }

    @Override
    public int getItemCount() {
        return super.getItemCount();
    }

    @Override
    protected void convert(BaseViewHolder helper, LoginBean.MenuListBean item, int position) {
        LinearLayout ll_item = (LinearLayout) helper.getView(R.id.ll_item);
        TextView tv = (TextView) helper.getView(R.id.tv);
        tv.setText(item.getType_name());
        if(item.isSelect()){
            ll_item.setBackgroundResource(R.color.white);
            tv.setTextColor(context.getResources().getColor(R.color.my_titler));
        }else{
            ll_item.setBackgroundResource(R.color.my_color);
            tv.setTextColor(context.getResources().getColor(R.color.home_tv_extra));
        }
    }
}
